package com.qyc.controller;

import com.qyc.dto.AddOrUpdateQuarantineRegistrationDTO;
import com.qyc.service.QuarantineRegistrationService;
import com.qyc.utils.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @className: QuarantineRegistrationController
 * @Description: 质检管理Controller层代码
 * @author: qinyc
 * @date: 2023/6/23 22:59
 * @version: v1.0
 */
@Api(tags = "质检管理")
@RestController
@RequestMapping("/quarantineRegistration")
public class QuarantineRegistrationController {
    //注入质检管理Service层对象
    @Autowired
    private QuarantineRegistrationService quarantineRegistrationService;
    
    /**
     * @Author qinyc
     * @Description  分页多条件查询检疫记录
     * @version: v1.0
     * @Date 23:03 2023/6/23
     **/
    @ApiOperation("分页多条件查询检疫记录")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "bQualified",value = "检疫结果：合格或不合格"),
            @ApiImplicitParam(name = "grMechanism",value = "检疫机构，支持模糊查询"),
            @ApiImplicitParam(name = "pageNum",value = "当前页码"),
            @ApiImplicitParam(name = "pageSize",value = "每页大小")
    })
    @GetMapping("/query")
    public ResponseResult queryPage(String bQualified,String grMechanism,Integer pageNum,Integer pageSize){
        return quarantineRegistrationService.queryPage(bQualified,grMechanism,pageNum,pageSize);
    }
    
    /**
     * @Author qinyc
     * @Description  新增或更新检疫记录
     * @version: v1.0
     * @Date 23:30 2023/6/23
     **/
    @ApiOperation("新增或更新检疫记录")
    @PostMapping("/saveOrUpdate")
    public ResponseResult saveOrUpdate(@RequestBody AddOrUpdateQuarantineRegistrationDTO addOrUpdateQuarantineRegistrationDTO){
        return quarantineRegistrationService.saveOrUpdate(addOrUpdateQuarantineRegistrationDTO);
    }
    
    
    /**
     * @Author qinyc
     * @Description  根据检疫id删除检疫记录
     * @version: v1.0
     * @Date 10:12 2023/6/24
     **/
    @ApiOperation("根据检疫id删除检疫记录")
    @DeleteMapping("/deleteById/{grId}")
    public ResponseResult deleteById(@PathVariable("grId") Integer grId){
        return quarantineRegistrationService.deleteById(grId);
    }
    
    /**
     * @Author qinyc
     * @Description  批量删除检疫记录
     * @version: v1.0
     * @Date 10:46 2023/6/24
     **/
    @ApiOperation("批量删除检疫记录")
    @DeleteMapping("/deleteByIdAll")
    public ResponseResult deleteByIdAll(@RequestBody List<Integer> grIds){
        return quarantineRegistrationService.deleteByIdAll(grIds);
    }
}
